const mongoose = require("./db");
const Schema = mongoose.Schema;
const Model = mongoose.model;

const cronySchema = Schema({
  name: String,
  password: String,
  avatar: String,
  cronylist: {
    type: Array,
    default: [],
  },
});

const MessageSchema = Schema(
  {
    message: String,
    // 获取双方的id
    cronys: Array,
    // 发送者的id
    sender: {
      type: Schema.Types.ObjectId,
    },
    xls:String,
    emjoy: String,
    basevideo: String,//音频
    basevoice:String,//视频
    voicetime: Number,
    name:String,
    address:String,
    latitude:String,
    longitude:String,
    types:Number,
    time:Date
  },
  {
    timestamps: true,
  }
);

const cronyModel = Model("crony", cronySchema, "crony");
const messageModel = Model("message", MessageSchema, "message");

// cronyModel.create({
//     name: 'vv',
//     avatar: 'https://img2.baidu.com/it/u=3853345508,384760633&fm=253&fmt=auto&app=120&f=JPEG?w=800&h=1200',
// cronylist:['6504418fefa1a2af9d50a944','65044166ea09ad12625c282f']
// })

// messageModel.create({
//     message: 'sdd2222',
//     cronys: ['6504418fefa1a2af9d50a944','65044166ea09ad12625c282f'],
//     // 发送者的id
//     sender: '65044166ea09ad12625c282f'
// })

module.exports = {
  cronyModel,
  messageModel,
};
